<!doctype html>
<html class="no-js" lang="en">
<head>
	<title>Variable Time Step Loop Demo</title>

	<style>
	.page-width { width: 940px; margin: 0 auto; }
	#log { height: 50px; overflow-y: scroll; border: 1px solid gray; }
	</style>

</head>
<body>
  <header>
  		<div class="page-width">
			<h1>Variable Time Step Loop Demo</h1>
		</div>
  </header>
  <div role="main">
    	<div class="page-width">
			<div id="log"></div>
			<br>
			<a href="javascript:startLoop();">Start Loop</a>
			<a href="javascript:stopLoop();">Stop Loop</a>
			<br>&nbsp;
		</div>

  </div>
  <footer>
  		<div class="page-width">
<pre>
VariableTimeStepLoop - Allows easy creation of variable time step loops for your games or applications.

Copyright (c) 2012 Andrew Lundgren (http://grovebranch.net)
Licensed under the MIT License

http://code.google.com/p/variable-time-step-loop

Version: 1.0.0
</pre
		</div>
  </footer>
  
  	<!-- include the Variable Time Step Loop file -->
  	<script src="variable-time-step-loop-1.0.0.js"></script>

	<script>
		// basic logging, so we won't need console.log
		var logElement = document.getElementById("log");
		function log(msg) {
			logElement.innerHTML = msg;// + "<br />" + logElement.innerHTML;
			if( console.log ) {
				console.log(msg);
			}
		}
		
		// declare the loop - update handler declared in-line
		var myGameLoop = new VariableTimeStepLoop(function(elapsedSeconds) {
			log("Update event fired! Seconds elapsed: " + elapsedSeconds);
		});

		// slow the loop a bit, so it's human-friendly to display iterations
     //myGameLoop.updateDelay = 100;

		// hook the onStart event for testing purposes
		myGameLoop.onStart = function() {
			log("Loop started!");
		}

		// hook the onStop event for testing purposes
		myGameLoop.onStop = function() {
			log("Loop stopped!");
		}

		// start the loop
		myGameLoop.start();
	
		// handler for "start loop" hyperlink
		function startLoop() {
			if( !myGameLoop.isOn ) {
				myGameLoop.start();
			}
		}
	
		// handler for "stop loop" hyperlink
		function stopLoop() {
			if( myGameLoop.isOn ) {
				myGameLoop.stop();
			}
		}

	</script>
</body>
</html>
